package org.lex.jdbc.url;

import java.util.ArrayList;
import java.util.List;

public class JdbcUrlTemplate extends CommonObject {
	public JdbcUrlTemplate initialize(String name, String template,
			DriverConfig driver) {
		this.setName(name);
		this.setDescription(name);
		this.setDriver(driver);
		this.setTemplate(template);
		return this;
	}

	private DriverConfig driver = null;
	private String template = "";
	private List<Variable> variables = new ArrayList<Variable>();

	public DriverConfig getDriver() {
		return driver;
	}

	public void setDriver(DriverConfig driver) {
		this.driver = driver;
	}

	public String getTemplate() {
		return template;
	}

	public void setTemplate(String template) {
		this.template = template;
		this.variables = new JdbcUrlBuilder().parseVariables(template);
	}

	public JdbcUrlTemplate addVadiable(Variable var) {
		variables.add(var);
		return this;
	}

	public List<Variable> getVariables() {
		return variables;
	}
}
